<?php
namespace app\services\ai\traits\qq;

trait Translate
{
    public function textTrans($options)
    {
        return $this->request(self::POST, self::API_NLP_TEXT_TRANS, $this->parseOptions([
            'text' => $options['text'] ?? '',
            'type' => $options['type'] ?? 0,
        ]));
    }

    public function textTranslate($options)
    {
        return $this->request(self::POST, self::API_NLP_TEXT_TRANSLATE, $this->parseOptions([
            'text' => $options['text'] ?? '',
            'source' => $options['source'] ?? 'zh',
            'target' => $options['target'] ?? 'en',
        ]));
    }

    public function imageTranslate($options)
    {
        return $this->request(self::POST, self::API_NLP_IMAGE_TRANSLATE, $this->parseOptions([
            'image' => $options['image'] ?? '',
            'scene' => $options['scene'] ?? 'doc',
            'source' => $options['source'] ?? 'zh',
            'target' => $options['target'] ?? 'en',
            'session_id' => str_random(64),
        ]));
    }
}
